﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace WindowsGame1
{
    class Card
    {
        #region Constants
        //none
        #endregion

        #region Fields

        //Position of card
        public Vector2 Position;

        //texture applied to card
        Texture2D cardTexture;

        //Player number set by gamer.id
        public int playerNum;

        //screensize
        Vector2 screenSize;

        //Vector for cardInput
        public Vector2 cardInput;

        //Card texture is transparent, this sets its color
        public Color cardColor;
        
        //tells whether or not to call a funciton to update opponents player turn
        public bool updatePlayerTurn;

        //turn
        public byte playerTurn;

        #endregion



        public Card(int gamerIndex, ContentManager content,
                   int screenWidth, int screenHeight)
        {

            // Use the gamer index to compute a starting position, so each player
            // starts in a different place as opposed to all on top of each other.
            Position.X = screenWidth / 4 + (gamerIndex % 5) * screenWidth / 8;
            Position.Y = screenHeight / 4 + (gamerIndex / 5) * screenHeight / 5;

            playerNum = gamerIndex;

            cardTexture = content.Load<Texture2D>("transparentCard");

            screenSize = new Vector2(screenWidth, screenHeight);

            updatePlayerTurn = false;

            playerTurn = 42;

            switch (gamerIndex)
            {
                case 0:
                    {
                        cardColor = new Color(0, 0, 255, 255);
                        break;
                    }
                case 1:
                    {
                        cardColor = new Color(255, 0, 0, 255);
                        break;
                    }
            }

        }

        public void Update()
        {

#if WINDOWS
                Position += cardInput;
#endif
#if XBOX
            cardInput.Y *= -1;
            Position += cardInput;
#endif


        }


        public void Draw(SpriteBatch spriteBatch)
        {
            Vector2 origin = new Vector2(cardTexture.Width / 2, cardTexture.Height / 2);

            spriteBatch.Draw(cardTexture, Position, cardColor);
        }
    }
}
